#ifndef ACCTAUTHENTICATE_H
#define ACCTAUTHENTICATE_H

#include <QObject>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>

#ifndef _WIN32
#include <unistd.h>
#include <wait.h>
#include <fcntl.h>
#include <security/pam_appl.h>
#include <sys/mman.h>
#endif

/**
 * @brief The AcctAuthenticate class
 * user name and password login authenticate
 * on linux based on pam_authenticate
 */
class AcctAuthenticate : public QObject
{
    Q_OBJECT
public:
    explicit AcctAuthenticate(QObject *parent = nullptr);
    ~AcctAuthenticate();

#ifndef _WIN32

public:
    bool pam_module_init(const char* username);
    bool pam_module_auth(const char* passwd);
    void pam_module_finit();

private:
    static int pam_conv_callback(int msgId, const pam_message **msg, pam_response **resp, void *appData);

private:
    pam_handle_t *mPamHandle = 0;
    pam_conv mConv;
    const char *mPassword = 0;

#endif


signals:

};

#endif // ACCTAUTHENTICATE_H
